#include <string.h>
#include "unikat.h"
#include "jadro.h"
#include "rbstrom.cc"

long Qstrom_cmp(Qstrom*t1,Qstrom*t2){
  int cmp=strcmp(t1->vobsah(),t2->vobsah());
  if(cmp) return cmp;
  Qstrom *s1,*s2;
  s1=t1->vsyn();
  s2=t2->vsyn();
  if(s1==s2) cmp=0;
  else if(s1&&s2) cmp=Qstrom_cmp(s1,s2);
  else if(s1) return 1;
  else return -1;
  if(cmp) return cmp;
  s1=t1->vbratr();
  s2=t2->vbratr();
  if(s1==s2) return 0;
  else if(s1&&s2) return Qstrom_cmp(s1,s2);
  else if(s1) return 1;
  else return -1;
}

int Ustrom::unikat(Qstrom *&t){
  Qstrom *s=t;
  t=this->t->pridej(t);
  if(s!=t){
    s->pocminus();
    t->pocplus();
    return 1;
  }else return 0;
}


int Ustrom::zrus(Qstrom *s){
  return t->uber(s);
}
